
/**
 * 在这里给出对类 Combat 的描述。
 * 
 * @作者（你的名字）
 * @版本（一个版本号或者一个日期）
 */
public class Combat
{
    public Combat()
    {
        ;
    }
    public void combats(Player player,Monster monster)
    {
        String monsterName = monster.getName();
        while(player.getLife()>0 && monster.getLife()>0 && player.getBlue() >= 0)
        {
            int baoji = (int)(Math.random()*5);
            int hurt = player.getAttack()-monster.getDefense() + baoji;
            int bl = 5 + (int)(Math.random()*5);
            if(hurt <= 0) hurt=0;
            monster.setLife(-hurt);
            player.setBlue(-bl);
            System.out.println("你对"+monsterName+"造成"+hurt+"伤害!");
            System.out.println("你消耗了" + bl + "点真气");
            hurt = monster.getAttack()-player.getDefense();
            if(hurt<0) hurt=0;
            System.out.println(monsterName+"对你造成"+hurt+"伤害!");
            player.setLife(-hurt);
            System.out.println(monsterName+"剩余血量:"+monster.getLife());
        }
        
        if(player.getLife() > 0 && player.getBlue() >= 0)  
        {
            System.out.println("战胜了" + monsterName);
        }
    }
}
